from cryptography.fernet import Fernet

# 生成密钥
# key = Fernet.generate_key()
# print(key)
key = b'7oMahiLQ2N-LJBxa2hwL4lwpjEOCxa1t18SQ_x_qCGg='
cipher_suite = Fernet(key)

# 待加密的数据
data = {"a":'4'}

# 将列表转换为字符串
data_str = str(data)

# 加密数据
encrypted_data = cipher_suite.encrypt(data_str.encode())

# 打印加密后的数据
print("Encrypted:", encrypted_data)

# 解密数据
decrypted_data = cipher_suite.decrypt(encrypted_data).decode()

# 将解密后的字符串转换回列表
decrypted_list = eval(decrypted_data)

print("Decrypted:", decrypted_list)